package com.sxsihe.heartmate;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;

/**
 * Created by mac on 16/10/22.
 */
public class WebviewActivity extends Activity implements View.OnClickListener {
    ImageView back_icon;
    public void onCreate(Bundle bundle){
        super.onCreate(bundle);
        setContentView(R.layout.webview);

        back_icon = (ImageView)findViewById(R.id.back_icon);
        back_icon.setOnClickListener(this);

        WebView webview = (WebView) findViewById(R.id.webview);
        webview.getSettings().setJavaScriptEnabled(true);

        webview.loadUrl("http://baidu.com");
        webview.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                // TODO Auto-generated method stub
                //返回值是true的时候控制去WebView打开，为false调用系统浏览器或第三方浏览器
                view.loadUrl(url);
                return true;
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.back_icon:
                finish();
                overridePendingTransition(R.anim.in_left, R.anim.out_right);
                break;
        }
    }
}
